package xin.marcher.module.comment.converter;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import xin.marcher.module.comment.domain.dto.SkuCommentDTO;
import xin.marcher.module.comment.domain.dto.SkuWaitCommentDTO;
import xin.marcher.module.comment.domain.entity.SkuCommentDO;
import xin.marcher.module.comment.domain.entity.SkuWaitCommentDO;
import xin.marcher.module.comment.domain.request.SkuCommentRequest;
import xin.marcher.module.comment.domain.request.SkuWaitCommentRequst;
import xin.marcher.module.common.core.PageResult;

import java.util.List;

/**
 *
 */
@Mapper(componentModel = "spring")
public interface SkuCommentConverter {

    /**
     * 对象克隆
     */
    @Mapping(target = "updateUser", source = "operateUser")
    SkuWaitCommentDO convertWaitComment(SkuWaitCommentRequst request);

    /**
     * 对象克隆
     */
    @Mappings({
            @Mapping(target = "content", source = "records"),
            @Mapping(target = "totalElements", source = "total"),
            @Mapping(target = "number", source = "current"),
            @Mapping(target = "totalPages", source = "pages"),
    })
    PageResult<SkuWaitCommentDTO> convertWaitCommentPage(Page<SkuWaitCommentDO> pageResult);

    /**
     * 对象克隆
     */
    @Mapping(target = "updateUser", source = "operateUser")
    SkuCommentDO convertComment(SkuCommentRequest request);

    /**
     * 对象克隆
     */
    SkuWaitCommentDTO convertWaitCommentDTO(SkuWaitCommentDO skuWaitCommentDO);

    /**
     * 对象克隆
     */
    @Mappings({
            @Mapping(target = "content", source = "records"),
            @Mapping(target = "totalElements", source = "total"),
            @Mapping(target = "number", source = "current"),
            @Mapping(target = "totalPages", source = "pages"),
    })
    PageResult<SkuCommentDTO> convertCommentPage(Page<SkuCommentDO> pageResult);

    /**
     * 对象克隆
     */
    List<SkuWaitCommentDTO> convertSkuWaitCommentDTOList(List<SkuWaitCommentDO> records);

}
